﻿using EntityModel.PageListInfor;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Threading.Tasks;

namespace IServices.ICurrency
{
    /// <summary>
    /// 通用接口
    /// </summary>
    public interface ICurrencyServer
    {
        /// <summary>
        /// 成功返回参数
        /// </summary>
        /// <param name="obj">返回的数据</param>
        /// <returns></returns>
        public IActionResult Success(object obj);

        /// <summary>
        /// 失败返回参数
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public IActionResult Fail(string obj);

        /// <summary>
        /// 执行sql
        /// </summary>
        /// <param name="crmSqlConnect">连接字符串</param>
        /// <param name="sql">SQL语句</param>
        /// <param name="sqlParameters">可为空的参数</param>
        /// <returns></returns>
        DataTable ExecuteSqlAsync(string crmSqlConnect, string sql, SqlParameter[] sqlParameters = null);

        /// <summary>
        /// 使用SQL Server 的Row_Number()函数进行分页查询的方法
        /// </summary>
        /// <param name="table">表名</param>
        /// <param name="pk">主键</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">当前显示行数</param>
        /// <param name="sortBy">排序字段：只能对应一个字段</param>
        /// <param name="sortOrder">排序类型</param>
        /// <param name="filter">查询条件：不带WHERE，可以是多个条件的组合</param>
        /// <param name="isCount">是否显示总数</param>
        /// <param name="selectFields">查询输出字段列表</param>
        /// <returns></returns>
        Task<DbQueryResult> PagingByRownumber(string table, string pk, int pageIndex, int pageSize, string sortBy
          , SortAction sortOrder, string filter, bool isCount, string selectFields);

        /// <summary>
        /// 增删改sql
        /// </summary>
        /// <param name="coon">数据库连接串</param>
        /// <param name="sql">sql语句</param>
        /// <returns></returns>
        int DeletUpdateCreateSql(string coon, string sql);

        /// <summary>
        /// 中文转英文（获取中文首字母）
        /// </summary>
        /// <param name="chinese">中文汉字</param>
        /// <returns></returns>
        Task<string> InTheSwap(string chinese);
    }
}
